<?php
$iipp=$_SERVER["REMOTE_ADDR"];

$mmsid=$_GET['vid'];

//$url1='http://dynamic.meizi.app.m.letv.com/android/dynamic.php?mod=minfo&ctl=videofile&act=index&playid=0&tss=ios&pcode=010610000&version=1.9&mmsid='.$mmsid;

$url1='http://dynamic.meizi.app.m.letv.com/android/dynamic.php?mod=minfo&ctl=videofile&act=index&playid=0&tss=ios&pcode=010210000&version=6.4&mmsid='.$mmsid;

$data=file_data($url1,$iipp);

$json=json_decode($data);

$array = object_array($json);



$url2=$array['body']['videofile']['infos']['mp4_1000']['backUrl2'];
if(empty($url2)) $url2=$array['body']['videofile']['infos']['mp4_350']['backUrl2'];

$data2=file_data($url2,$iipp);

$json2=json_decode($data2);

$array2 = object_array($json2);

$video=$array2['location'];



//die($video);

header('Content-Type:application/force-download');
header("Location:".$video);



function file_data($url,$ip) {

                        $header = 'User-Agent: Linux; U; Android 2.3.4; fr-fr; Nexus S Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1';

                        $ch = curl_init ();

                        $timeout = 30;

                        curl_setopt ( $ch, CURLOPT_URL, $url );

						curl_setopt ( $ch, CURLOPT_HTTPHEADER, array( 'CLIENT-IP:'.$ip, 'X-FORWARDED-FOR:'.$ip));

                        curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );

                        curl_setopt ( $ch, CURLOPT_CONNECTTIMEOUT, $timeout );

                        curl_setopt ( $ch, CURLOPT_USERAGENT, $header );

                        @ $c = curl_exec ( $ch );

                        curl_close ( $ch );

                        return $c;

        }


function object_array($array){
  if(is_object($array)){
    $array = (array)$array;
  }
  if(is_array($array)){
    foreach($array as $key=>$value){
      $array[$key] = object_array($value);
    }
  }
  return $array;
} 

		

		?>